package com.hyp.service.impl;

import com.hyp.mapper.EmpMapper;
import com.hyp.pojo.Emp;
import com.hyp.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class EmpServiceImpI implements EmpService {
    @Autowired
    private EmpMapper empMapper;

    @Override
    public Emp login(Emp emp) {
        Emp e = empMapper.getByEmpnameAndEmpPassword(emp);
        return e;
    }

    @Override
    public List<Emp> list() {
        return empMapper.list();
    }


    @Override
    public Emp getById(Integer id) {
        return empMapper.getById(id);
    }

    @Override
    public void update(Emp emp) {
        emp.setUpdatedAt(LocalDateTime.now());
        empMapper.update(emp);
    }

    @Override
    public void addSave(Emp emp) {
        emp.setCreatedAt(LocalDateTime.now());
        emp.setUpdatedAt(LocalDateTime.now());
        empMapper.addSave(emp);
    }

    @Override
    public void delete(Integer id) {
        empMapper.delete(id);
    }


}
